<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" import="java.net.URLEncoder"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>总数详细信息</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>
<link href="<%=request.getContextPath()%>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/fare/js/jquery-1.6.4.min.js"></script>
<link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<!-- <script src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script> -->

    
     <script type="text/javascript">
     var columns=[ 
  	 			{  display : '序号',	width:  40, 
  	 				render: function(data, index) { return (this.options.page-1)*this.options.pageSize+index+1;}
  	 		    },
  	 		    {display : '航段',width : 180,name : 'leg'},
  	 			/* {display : '查看详情',width : 70,
  	 				render: function (record, rowindex, value, column) {
  	 					return "<a href=\"javaScript:open_HBase_detail(\'"+record.sourceRowkey+"\');\">查看详情</a>";
  	 				   }
  	 			}, */
  	 			{display: 'fromCity',width:1, name: 'fromCity',hide:true },
  	 			{display: 'toCity',width:1, name: 'toCity',hide:true },
  	 			{display: 'grabchannel',width:1, name:'grabchannel',hide:true},
  	 			
  	 		/* 	{display : '流量大小(b)', width : 100,name : 'allbyteLength'},  */
  	 			{display : '流量大小(m)', width : 100,
  	 				render: function (record, rowindex, value, column){
  	 					
	 					 	return (record.allbyteLength/(1024*1024)).toFixed(2);
	 					 }
  	 			}, 
  	 		/* 	{display : '源数据大小(b)', width : 100,name : 'sourceDataSize'},  */
  	 			{display : '源数据大小(m)', width : 100,
  	 				render: function (record, rowindex, value, column){
  	 					
 					 	return (record.sourceDataSize/(1024*1024)).toFixed(2);
 					 }
  	 			},
  	 			{display : '实际总数', width : 100,align:'center',
  	 				 render: function (record, rowindex, value, column){
  	 					var leg =rowindex.leg;
	 					 	return "<a href=\"javaScript:open_detail_3("+leg+");\">"+record.total+"</a>";
	 					 } 
  	 			},
  	 			{display : '失败总数', width : 100,align:'center',
  	 				 render: function (record, rowindex, value, column){
	 						var leg =rowindex.leg;
	 					 	return "<a href=\"javaScript:open_detail_4("+leg+");\">"+record.failNum+"</a>";
	 					 } 
  	 			},
  	 			{display : '成功总数', width : 100,align:'center',name : 'successNum',
  	 				 render: function (record, rowindex, value, column){
  	 					var status =3;
 					 	return "<a href=\"javaScript:open_detail("+status+");\">"+record.successNum+"</a>";
 					 } 
	 			},
  	 			{ display:'成功率',width: 70,align:'center',
  	 				render:function (row){
  	 					if(row.total==0)
  	 						return "<b style=\'color:red\'>"+"0%"+"</b>";
  	 					else if(row.successNum/row.total<0.5)
  	 						return "<b style=\'color:red\'>"+Math.round(row.successNum/row.total * 1000)/10+"%"+"</b>";
  	 					else
  	 						return "<b style=\'color:green\'>"+Math.round(row.successNum/row.total * 1000)/10+"%"+"</b>";
  	 				}
  	 			},
  	 			
  	 			{ display: '状态统计', columns:
  	 				[
  	 				{ display: '抓取失败', name: 'secondFail',width:60, align:'center',
  	 					//查看详细失败信息
  	 					 render: function (record, rowindex, value, column){
  	 						var status='-2';
  	 					 	return "<a href=\"javaScript:open_detail("+status+");\">"+record.secondFail+"</a>";
  	 					 }
  	 			   },
  	 			   { display: '解析失败', name: 'thirdFail',width:60, align:'center',
  	 				 	 render: function (record, rowindex, value, column) {
  	 				 		var status='-3';
  	 				 		return "<a href=\"javaScript:open_detail("+status+");\">"+record.thirdFail+"</a>";
  	 				 	 }
  	 				 	 },
  	 			   { display: '其他失败', name: 'forthFail',width:60, align:'center',
  	 					render: function (record, rowindex, value, column){ 
  	 						var status='-4';
  	 						return "<a href=\"javaScript:open_detail("+status+");\">"+record.forthFail+"</a>";
  	 					}
  	 				},
  	 				{ display: '等待中', name: 'waiting',width:60, align:'center',
  	 				 	 render: function (record, rowindex, value, column) {
  	 				 		var status='0';
  	 				 		return "<a href=\"javaScript:open_detail("+status+");\">"+record.waiting+"</a>";
  	 				 	 }
  	 				},
  	 				
  	 				{ display: '执行中', name: 'working',width:60, align:'center',
  	 				 	 render: function (record, rowindex, value, column) {
  	 				 		var status='1';
  	 				 		return "<a href=\"javaScript:open_detail("+status+");\">"+record.starting+"</a>";
  	 				 	 }
  	 				}
  	 				]
  	 			},
  	 			{ display: '耗时统计', columns:
  	 				[
					{display:  '执行最大时间(秒)',width : 100,name:'maxTime'},
					{display:  '执行最小时间(秒)',width : 100,name:'minTime'},
					{display : '执行平均时间(秒)',width : 100,	name : 'avgTime'}
  	 				]
  	 			},
  	 			
  	 			{display : '实际抓取数量',width : 80,	name : 'actualNum'},
  	 			];
     
        $(function () {
        	var grabchannelID=GetQueryString("grabchannelID");
        	var grabdate=GetQueryString("grabdate");
			var url="<%=request.getContextPath() %>/taskRecordAction!findTotalDetailInfo.action?grabdate="+grabdate+"&grabchannelID="+grabchannelID;
        	   $("#maingrid").ligerGrid({
        		    dataAction : 'server',
        		    title:'任务详细信息',
					showTitle:true,
				 	url:url,
				    columns : columns,
				    height: '100%',
			        width: '100%',
			        usePager:false,
			        /*AllowPaging:false,
			        pageSizeOptions : [20,30,50,100],
					pageSize:20, 
					pagesizeParmName:'pagesize' ,
					rownumbers:true,
	                enabledEdit: true,
	                checkbox : false,
	                clickToEdit:false, 
			        isScroll: true,*/
	                heightDiff: -6
        	 	});   
        });
        
        function GetQueryString(name)  
        {  
            var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)");  
            var r= window.location.search.substr(1).match(reg);  
            if (r!=null) return unescape(r[2]);return null;  
        }        
        
        //失败总数
         function open_detail_4(leg)
        {
        	var manager = $("#maingrid").ligerGetGridManager();
        	var row = manager.getSelectedRow();
        	var grabchannelID=GetQueryString("grabchannelID");
        	var grabdate=GetQueryString("grabdate");

        	var url='<%=request.getContextPath() %>/fare/view_tatol_and_fail_detail.jsp?&grabchannelID='+grabchannelID+'&grabchannel='+row.grabchannel+'&grabdate='+grabdate+'&fromCity='+row.fromCity+'&toCity='+row.toCity+'&leg='+row.leg+'&rd='+Math.random();;
        	parent.f_addTab("total_3","总次数_失败总数", url);
        }
        
      //弹出任务失败状态的详细信息	
        function open_detail(status)
        {	
        	var manager = $("#maingrid").ligerGetGridManager();
        	var row = manager.getSelectedRow();
        	var grabchannelID=GetQueryString("grabchannelID");
        	var grabdate=GetQueryString("grabdate");
        	var url='<%=request.getContextPath() %>/fare/view_tatol_fail_detail.jsp?&status='+status+'&grabchannelID='+grabchannelID+'&grabchannel='+row.grabchannel+'&grabdate='+grabdate+'&fromCity='+row.fromCity+'&toCity='+row.toCity+'&leg='+row.leg+'&rd='+Math.random();;
        	var showTest;
        	var testG;
        	if(status==3){
        		showTest="成功总数";
        		testG="total_4";
        	}
        	if(status==-2){
        		showTest="抓取失败";
        		testG="total_5";
        	}
        	if(status==-3){
        		showTest="解析失败";
        		testG="total_6";
        	}
        	if(status==-4){
        		showTest="其他失败";
        		testG="total_7";
        	}
        	if(status==0){
        		showTest="等等中";
        		testG="total_8";
        	}
        	if(status==1){
        		showTest="执行中";
        		testG="total_9";
        	}
        	parent.f_addTab(""+testG+"","总次数_"+showTest+"", url);
        }
      
      //成功总数和失败总数的跳转页面信息
      function open_detail_3(leg)
        {
        	var manager = $("#maingrid").ligerGetGridManager();
        	var row = manager.getSelectedRow();
        	var grabchannelID=GetQueryString("grabchannelID");
        	var grabdate=GetQueryString("grabdate");
        	var url='<%=request.getContextPath() %>/fare/view_total_all_detail.jsp?&grabchannelID='+grabchannelID+'&grabchannel='+row.grabchannel+'&grabdate='+grabdate+'&fromCity='+row.fromCity+'&toCity='+row.toCity+'&leg='+row.leg+'&rd='+Math.random();;
        	parent.f_addTab("total_2","总次数_实际总数", url);
        }
        
        
        function open_HBase_detail(sourceRowKey){
        	if($.trim(sourceRowKey).length>0){
        		 $.ajax({
        			  url: "<%=request.getContextPath() %>/taskRecordAction!fetchContent.action?sourceRowKey="+$.trim(sourceRowKey),
        			  cache: false,
        			  success: function(data){
        				  //var OpenWindow=window.showModalDialog("test.html?data="+data, data, "dialogWidth=200px;dialogHeight=100px"); 
        				  //var OpenWindow=window.showModalDialog("http://www.bejson.com/go.html?u=http://www.bejson.com/jsonview2/","JSON详情", "  width=4000,toolbar=yes,scrollbars=yes,menubar=yes",false);
        				  var OpenWindow=window.open("test.html", "HBase详情", "height=1000,width=4000,toolbar=yes,scrollbars=yes,menubar=yes",false); 
        				  OpenWindow.document.write(data) ;
        			  } 
        			});
        	}else{
        		 $.ligerDialog.warn('HBase的sourceRowKey为空');
        	}
        }
        
        function mergecell(gridid, columnid) //参数:表格id和列索引关键字，根据表格具体值来动态合并单元格
        {
            var i, j, k, x;
            i = -1; k = 1; j = ""; x = 0;
            var cellname = "";

            $("td[id$='|" + columnid + "']", gridid).each(
                   function() {
                       if (j == $("div", this).text()) {
                           $(this).addClass("l-remove");
                           k++;
                           $("td[id='" + cellname + "']", gridid).attr("rowspan", k.toString());
                       }
                       else {
                           j = $("div", this).text();
                           var a = $(this);
                           cellname = a.attr("id"); //得到点击处的id                            
                           k = 1;
                           x = i;
                       }
                       i++;
                   });
            $(".l-remove").remove();
        }
        
       
    </script>   
    <script >
	function reload(){
		window.location.reload();
	}
	
	function closewin(){
		if (confirm("您确定要关闭本页吗？")){
			window.opener=null;
			window.open('','_self');
			window.close(); 
			/* var urls="fswInfoAction!getStatisticsTaskReport.action";
			window.location.href=urls; */
			}
			else{}

	}
	function returnF(){
		var urls="<%=request.getContextPath() %>/fswInfoAction!getStatisticsTaskReport.action";
		window.location.href=urls;
	}
	</script>
</head>




<body style="padding:10px">
		
	<form>
	<input name="fromCity" id="fromCity" type="hidden" value="${fromCity}"/>
	
	</form>
	
		<div id="reseachBy" >
		<table width="100%" cellpadding="0" cellspacing="5">
			<tr>
				<td align="left" width="95%">
					抓取渠道:&nbsp;&nbsp;
					<% String grabchannel=request.getParameter("grabchannel"); %>
					<%=new String(grabchannel.getBytes("ISO-8859-1"),"UTF-8")%>
					
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					 航班抓取日期:&nbsp;&nbsp;<%=request.getParameter("grabdate")%>
				
				</td>
				<td align="left">
					<!-- <input type="button" onclick="reload()" value="刷新"/> -->
					<!-- <input type="button" onclick="closewin()"  value="关闭"/> -->
					<!-- <input type="button" onclick="returnF()"  value="返回首页"/> -->
				
				</td>
			</tr>
		</table>
		</div>
	
    <div id="maingrid" style="margin-top: 0px">
    </div>
    <div id="results" style="margin-top: 20px">
    </div>
    <div id="re" align="center" style="width: 400;display:none;padding-top: 0px;">
		</div>
		
		
		
</body>
</html>
